#define _CRT_SECURE_NO_WARNINGS 1

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

const int N = 100000;
int n;
long long s[N], tmp[N];

long long merge_sort(int l, int r)
{
    if (l >= r) return 0;
    int mid = l + r >> 1;
    long long ans = merge_sort(l, mid) + merge_sort(mid + 1, r);

    int l1 = l, r1 = mid, l2 = mid + 1, r2 = r;
    int k = l;
    while (l1 <= r1 && l2 <= r2)
    {
        if (s[l1] <= s[l2])
        {
            tmp[k++] = s[l1++];
        }
        else
        {
            tmp[k++] = s[l2++];
            ans += r1 - l1 + 1;
        }
    }

    while (l1 <= r1) tmp[k++] = s[l1++];
    while (l2 <= r2) tmp[k++] = s[l2++];

    memcpy(s + l, tmp + l, sizeof(long long) * (r - l + 1));
    return ans;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &s[i]);
    }
    cout << merge_sort(0, n - 1) << endl;
    return 0;
}